package flc.ast.activity;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.os.Bundle;
import android.view.View;

import com.stark.picselect.entity.SelectMediaEntity;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.SelPictureAdapter;
import flc.ast.adapter.SelVideoAdapter;
import flc.ast.bean.MyImgBean;
import flc.ast.databinding.ActivityCollectPicBinding;
import flc.ast.utils.AppSpUtils;
import flc.ast.utils.MhzDateUtils;

public class CollectPicActivity extends BaseAc<ActivityCollectPicBinding> {

    private SelPictureAdapter selPictureAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_collect_pic;
    }

    @Override
    protected void initView() {
        mDataBinding.ivCollectPicBack.setOnClickListener(v -> onBackPressed());

        mDataBinding.rvPictureList.setLayoutManager(new LinearLayoutManager(mContext));
        selPictureAdapter = new SelPictureAdapter();
        selPictureAdapter.setCollect(true);
        mDataBinding.rvPictureList.setAdapter(selPictureAdapter);
        selPictureAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        getData();
    }

    private void getData() {
        List<String> listSp = AppSpUtils.getPicCollectList();
        if (listSp != null && listSp.size() > 0) {
            List<MyImgBean> dayData = MhzDateUtils.getDayData(listSp);
            selPictureAdapter.setList(dayData);
            mDataBinding.rvPictureList.setVisibility(View.VISIBLE);
            mDataBinding.tvPictureNoData.setVisibility(View.GONE);
        } else {
            mDataBinding.rvPictureList.setVisibility(View.GONE);
            mDataBinding.tvPictureNoData.setVisibility(View.VISIBLE);
        }
    }

}